package dk.dashboardFP.interactionElementFramwork.inputElement {	import dk.dashboardFP.panels.ui.text.label.InputLabel;	import dk.dashboardFP.interactionElementFramwork.focusHandler.IFocusRedirector;	import dk.dashboardFP.interactionElementFramwork.inputElementViews.TextInputView;	import flash.display.InteractiveObject;	import flash.events.FocusEvent;	/**
	 * @author jk
	 */
	public class TextInput extends AbstractInputElement implements IFocusRedirector {

		private var _doTextInputView : TextInputView;
		private var _sDefaultText : String;
		
		public function TextInput(doIEV : TextInputView, sDefaultText : String="") {
			_sDefaultText = sDefaultText;
			_doTextInputView = doIEV;
			super(doIEV);
			
			setupLabel();
		}
		
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// setup label
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		
		private function setupLabel() : void {
			_doTextInputView.doLabel.tfLabel.addEventListener(FocusEvent.FOCUS_IN, onTFFocusIn, false, 0, true);
			_doTextInputView.doLabel.tfLabel.addEventListener(FocusEvent.FOCUS_OUT, onTFFocusOut, false, 0, true);
			
		}

		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// text field focus handling
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		
		private function onTFFocusOut(event : FocusEvent) : void {
		}

		private function onTFFocusIn(event : FocusEvent) : void {
		}
		
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// focus direct to tb
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

		override protected function onFocusIn() : void {
			super.onFocusIn();
		}

		public function get oTargetInteractivityObject() : InteractiveObject {
			return _doTextInputView.doLabel.tfLabel;
		}
		
		public function get doInputLabel() : InputLabel { 
			return _doTextInputView.doLabel; 
		}
		
		public function get sValue() : String { 
			return _doTextInputView.doLabel.sText; 
		}
		
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// default value
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		
		public function get sDefaultValue() : String { 
			return _doTextInputView.doLabel.sDefaultText; 
		}
		
		public function set sDefaultValue(oNewValue : String) : void { 
			_doTextInputView.doLabel.sDefaultText = oNewValue; 
		}
		
		public function setDefaultValue() : void {
			_doTextInputView.doLabel.sText = _doTextInputView.doLabel.sDefaultText;
		}
		
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// validation
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		
		public function get bValidates() : Boolean { 
			return sValue!=sDefaultValue; 
		}
		
	}
}
